package com.polaris.live.viewmodel.live

import androidx.lifecycle.MutableLiveData
import com.polaris.live.common.mvvm.viewmodel.BaseViewModel
import com.polaris.live.common.network.request
import com.polaris.live.common.network.state.ResultState
import com.polaris.live.im.sfs.bean.live.ext.UserBasicVo
import com.polaris.live.net.liveService
import com.polaris.live.resp.base.ListResp
import com.polaris.live.widget.refresh.OnListListener

/**
 * RoomInfoViewModel
 *
 * @author Created by 半仙 on 2023/10/10/010 10:07
 */
class RoomInfoViewModel : BaseViewModel(), OnListListener {

    var fansLiveData = MutableLiveData<ResultState<ListResp<UserBasicVo>>>()

    private var userId: Long = 0
    private val pageSize = 20

    override fun onRefresh() {
        getFollowers(pageNumber = 0)
    }

    override fun onLoadMore(pageIndex: Int) {
        getFollowers(pageNumber = pageIndex)
    }

    private fun getFollowers(pageNumber: Int, pageSize: Int = this.pageSize) {
        request({ liveService.getPartyRoomFans(userId, pageNumber, pageSize) }, fansLiveData)
    }

    fun setUserId(userId: Long) {
        this.userId = userId
    }

}